package com.bridgeintelligent.tag.customer.controller;

import com.bridgeintelligent.tag.customer.entity.CustomersCodes;
import com.bridgeintelligent.tag.customer.entity.Result;
import com.bridgeintelligent.tag.customer.pojo.*;
import com.bridgeintelligent.tag.customer.service.StaticCustomersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;


@Api(tags = "客群管理")
@AllArgsConstructor
@RestController
@RequestMapping("/api/static/")
@Slf4j
public class StaticCustomersController {

    private StaticCustomersService service;

    /**
     * 获取静态客群的筛选条件信息(组装为动态格式返回)
     *
     * @return
     */
    @ApiOperation("获取静态客群的筛选条件信息(组装为动态格式返回)")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", name = "customersId", value = "客群id")})
    @GetMapping("/findFilters")
    public Result findStaticFilters(String customersId) {
        Customers customers = service.findStaticFilters(customersId);
        if (StringUtils.isNotEmpty(customers.getCustomersId())) {
            return new Result(CustomersCodes.SUCCESS, customers);
        } else {
            return new Result(-1, "客群不存在");
        }

    }


}